#include "window_common.h"

#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC
#if GKT_KEY_DOUBLE_LOCK_ENABLE && !GKT_KEY_DOUBLE_LOCK_MULTIPLEX
static int s_window_key_DOUBLE_LOCK_enable = 1;
void window_key_DOUBLE_LOCK_control(int enable)
{
	s_window_key_DOUBLE_LOCK_enable = enable;
}

static void window_key_DOUBLE_LOCK_handler(uint32_t *evt_data)
{
	gkt_unused(evt_data);

	if (s_window_key_DOUBLE_LOCK_enable
		&& window_door_lock_body_is_normal()) 
	{		
		gkt_window_show(WINDOW_ID_key_double_lock, 0);
	}
}
#else
void window_key_DOUBLE_LOCK_control(int enable)
{
	if (enable)
		gkt_key_enable_long_press(1U << GKT_KEY_DOUBLE_LOCK);
	else
		gkt_key_disable_long_press(1U << GKT_KEY_DOUBLE_LOCK);
}
#endif
#endif

void window_key_init(void)
{
#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC \
	&& GKT_KEY_DOUBLE_LOCK_ENABLE && !GKT_KEY_DOUBLE_LOCK_MULTIPLEX
	gkt_key_register_default_handler(GKT_KEY_DOUBLE_LOCK, 
		window_key_DOUBLE_LOCK_handler);
#endif
}

